﻿{include file="/public/header" /}
<div class="content-wraper" style="width: 100%;">
    <div class="panel mg10" style="padding: 15px;">        
        <form class="normal_form" onsubmit="return SysForm(this);" method="POST" autocomplete="off">
            <div class="r-panel-header" style="margin-bottom:8px;"><span class="panel-tit">账号信息</span></div>
            <div class="row">
                <div class="field_text">姓名：</div>
                <input type="text" name="realname" value="{$res['realname'] ?? ''}" class="input-text" disabled style="width:280px;" />
            </div>
            <div class="row">
                <div class="field_text">账户：</div>
                <input type="text" name="uname" value="{$res['uname'] ?? ''}" class="input-text" disabled style="width:280px;" />
            </div>

            <div class="row">
                <div class="field_text">性别：</div>
                <div class="labelrow">
                    <label class="l-radio"><input type="radio" name="gender" value="0" {if !isset($res['gender']) OR !$res['gender']}checked{/if} /><i></i><span>未知</span></label>
                    <label class="l-radio"><input type="radio" name="gender" value="1" {if isset($res['gender']) AND $res['gender']==1}checked{/if} /><i></i><span>男</span></label>
                    <label class="l-radio"><input type="radio" name="gender" value="2" {if isset($res['gender']) AND $res['gender']==2}checked{/if} /><i></i><span>女</span></label>
                </div>
            </div>

            <div class="r-panel-header" style="margin: 20px 0;"><span class="panel-tit">修改密码</span><i id="control-psw-box" class="icon-arrow close"></i></div>
            <div class="row" style="margin: 35px 0;">
                <div class="field_text">&nbsp;</div>
                <button type="reset" class="btn btn-cancel large">重置</button>
                <button type="submit" class="btn btn-primary large" style="margin-left: 15px;">保存</button>
            </div>
        </form>
        <div class="change-psw-box" style="display: none;">
            <div class="row toggle-psw">
                <div class="field_text">旧密码：</div>
                <input type="password" name="oldpassword" value="" class="input-text" placeholder="请输入旧密码" maxlength="50" />
                <div class="v-toggle-psw"></div>
            </div>
            <div class="row toggle-psw">
                <div class="field_text">新密码：</div>
                <input type="password" name="password" maxlength="20" class="input-text" placeholder="请输入新密码" maxlength="50" />
                <span style="margin-left:10px;">提示：密码长度8-50,字符大小写,特殊字符,数字(4选3)</span>
                <div class="v-toggle-psw"></div>
            </div>
            <div class="row toggle-psw">
                <div class="field_text">确认密码：</div>
                <input type="password" name="password2" maxlength="20" class="input-text" placeholder="请再次确认新密码" maxlength="50" />
                <div class="v-toggle-psw"></div>
                <!--<p class="colortip required_tip">新密码两次输入不一致 请重新输入</p>-->
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
SysForm = function(form){
    var form = $(form);
    var o    = null;
    form.find('.required_tip').remove();

    var column = ['oldpassword','password','password2'];
    for(var i in column) {
        if (!form.find('.change-psw-box').length) continue;

        o = form.find('.change-psw-box input[name="'+column[i]+'"]');
        if (column[i] == 'oldpassword' && o.val()!='' && !Core.rule('pwd',o.val())) {
            o.parents('div.row').append('<p class="colortip required_tip">请输入旧密码</p>');return false;
        } else if (column[i] == 'password' && o.val()!='' && !Core.rule('pwd',o.val())) {
            o.parents('div.row').append('<p class="colortip required_tip">请输入新密码</p>');return false;
        } else if (column[i] == 'password' && o.val()!='' && o.val()==form.find('input[name="oldpassword"]').val()) {
            o.parents('div.row').append('<p class="colortip required_tip">新密码不能和原密码一致，修改密码失败</p>');return false;
        } else if (column[i] == 'password2' && o.val()!='' && o.val()!=form.find('input[name="password"]').val()) {
            o.parents('div.row').append('<p class="colortip required_tip">两次输入的新密码不一致 请重新输</p>');return false;
        }
    }
    return Core.submit();
}
$(document).ready(function(){
    {if isset($spwd) AND $spwd=='1'}
    Core.Dialog.msg('重置密码成功!');return;
    {/if}
    $('#control-psw-box').on('click',function(){
        var _this = $(this);
        if(_this.hasClass('close')){
            $('.change-psw-box').clone(true).show().insertAfter(_this.parent('.r-panel-header'));
            _this.removeClass('close');
            return false;
        }else{
            _this.parent('.r-panel-header').next('.change-psw-box').remove();
            _this.addClass('close');
            return false;
        }
    });

    $('.v-toggle-psw').on('click',function(){
        $(this).toggleClass('open');
        $(this).parent('.toggle-psw').find('input').attr("type",$(this).hasClass("open") ? 'text' : 'password');
        if ($(this).hasClass("open")) {
            $(this).parent('.input-row').find('input').attr("type",'text');
        }
    });
});
</script>
{include file="/public/footer" /}